home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Interfaces&Libraries / Universal / Interfaces / CIncludes / OSA.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  54.4 KB  |  1,727 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        OSA.h
  3.  
  4.      Contains:    AppleScript Client Interfaces.
  5.  
  6.      Version:    Technology:    AppleScript 1.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1992-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __OSA__
  18. #define __OSA__
  19.  
  20. #ifndef __ERRORS__
  21. #include <Errors.h>
  22. #endif
  23. #ifndef __APPLEEVENTS__
  24. #include <AppleEvents.h>
  25. #endif
  26. #ifndef __AEOBJECTS__
  27. #include <AEObjects.h>
  28. #endif
  29. #ifndef __COMPONENTS__
  30. #include <Components.h>
  31. #endif
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55. /**************************************************************************
  56.     Types and Constants
  57. **************************************************************************/
  58.  
  59. /*    The componenent manager type code for components that
  60.         support the OSA interface defined here. */
  61. /* 0x6f736120 */
  62.  
  63. enum {
  64.     kOSAComponentType            = FOUR_CHAR_CODE('osa ')
  65. };
  66.  
  67. /* 0x73637074 */
  68.  
  69. enum {
  70.     kOSAGenericScriptingComponentSubtype = FOUR_CHAR_CODE('scpt')
  71. };
  72.  
  73. /*    Type of script document files.    */
  74. /* 0x6f736173 */
  75.  
  76. enum {
  77.     kOSAFileType                = FOUR_CHAR_CODE('osas')
  78. };
  79.  
  80. /*
  81.         Suite and event code of the RecordedText event. 
  82.         (See OSAStartRecording, below.)
  83.     */
  84. /* 0x61736372 */
  85.  
  86. enum {
  87.     kOSASuite                    = FOUR_CHAR_CODE('ascr')
  88. };
  89.  
  90. /* 0x72656364 */
  91.  
  92. enum {
  93.     kOSARecordedText            = FOUR_CHAR_CODE('recd')
  94. };
  95.  
  96. /* Selector returns boolean */
  97. /* 0x6d6f6469 */
  98.  
  99. enum {
  100.     kOSAScriptIsModified        = FOUR_CHAR_CODE('modi')
  101. };
  102.  
  103. /* Selector returns boolean */
  104. /* 0x63736372 */
  105.  
  106. enum {
  107.     kOSAScriptIsTypeCompiledScript = FOUR_CHAR_CODE('cscr')
  108. };
  109.  
  110. /* Selector returns boolean */
  111. /* 0x76616c75 */
  112.  
  113. enum {
  114.     kOSAScriptIsTypeScriptValue    = FOUR_CHAR_CODE('valu')
  115. };
  116.  
  117. /* Selector returns boolean */
  118. /* 0x636e7478 */
  119.  
  120. enum {
  121.     kOSAScriptIsTypeScriptContext = FOUR_CHAR_CODE('cntx')
  122. };
  123.  
  124. /* Selector returns a DescType which may be passed to OSACoerceToDesc */
  125. /* 0x62657374 */
  126.  
  127. enum {
  128.     kOSAScriptBestType            = FOUR_CHAR_CODE('best')
  129. };
  130.  
  131. /*
  132.         This selector is used to determine whether a script has source 
  133.         associated with it that when given to OSAGetSource, the call will not
  134.         fail.  The selector returns a boolean.
  135.     */
  136. /* 0x67737263 */
  137.  
  138. enum {
  139.     kOSACanGetSource            = FOUR_CHAR_CODE('gsrc')
  140. };
  141.  
  142.  
  143.  
  144. enum {
  145.     typeOSADialectInfo            = FOUR_CHAR_CODE('difo'),        /*  0x6469666f   */
  146.     keyOSADialectName            = FOUR_CHAR_CODE('dnam'),        /*  0x646e616d   */
  147.     keyOSADialectCode            = FOUR_CHAR_CODE('dcod'),        /*  0x64636f64   */
  148.     keyOSADialectLangCode        = FOUR_CHAR_CODE('dlcd'),        /*  0x646c6364   */
  149.     keyOSADialectScriptCode        = FOUR_CHAR_CODE('dscd')        /*  0x64736364   */
  150. };
  151.  
  152. typedef ComponentResult                 OSAError;
  153. /* Under the Open Scripting Architecture all error results are longs */
  154. typedef unsigned long                     OSAID;
  155. /*
  156.         OSAIDs allow transparent manipulation of scripts associated with
  157.          various scripting systems.
  158.     */
  159.  
  160. enum {
  161.     kOSANullScript                = 0L
  162. };
  163.  
  164. /* No -script constant. */
  165.  
  166. enum {
  167.     kOSANullMode                = 0,                            /* sounds better */
  168.     kOSAModeNull                = 0                                /* tastes consistent */
  169. };
  170.  
  171. /*
  172.         Some routines take flags that control their execution.  This constant
  173.         declares default mode settings are used.
  174.     */
  175. typedef CALLBACK_API( OSErr , OSACreateAppleEventProcPtr )(AEEventClass theAEEventClass, AEEventID theAEEventID, const AEAddressDesc *target, short returnID, long transactionID, AppleEvent *result, long refCon);
  176. typedef CALLBACK_API( OSErr , OSASendProcPtr )(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc, long refCon);
  177. typedef STACK_UPP_TYPE(OSACreateAppleEventProcPtr)                 OSACreateAppleEventUPP;
  178. typedef STACK_UPP_TYPE(OSASendProcPtr)                             OSASendUPP;
  179. enum { uppOSACreateAppleEventProcInfo = 0x000FEFE0 };             /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes, 2_bytes, 4_bytes, 4_bytes, 4_bytes) */
  180. enum { uppOSASendProcInfo = 0x003FEFE0 };                         /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes, 2_bytes, 4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  181. #define NewOSACreateAppleEventProc(userRoutine)                 (OSACreateAppleEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, GetCurrentArchitecture())
  182. #define NewOSASendProc(userRoutine)                             (OSASendUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSASendProcInfo, GetCurrentArchitecture())
  183. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)  CALL_SEVEN_PARAMETER_UPP((userRoutine), uppOSACreateAppleEventProcInfo, (theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  184. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)  CALL_EIGHT_PARAMETER_UPP((userRoutine), uppOSASendProcInfo, (theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  185. /**************************************************************************
  186.     Standard Script Errors
  187. **************************************************************************
  188.     It is recommended that scripting components use the following set of error
  189.     codes to signal failure when applicable.  This enables applications that
  190.     use the OSA API to deal with some class of script errors in a less than 
  191.     ad hoc manner.  Scripting components are of course encouraged to return
  192.     component-specific errors when these don't apply.
  193. **************************************************************************/
  194. /*        Dynamic errors:
  195.  
  196.     These errors result from data-dependent conditions and are typically
  197.     signaled at runtime.
  198. */
  199. /*
  200.         Signaled when a value can't be coerced to the desired type. Similar
  201.           to errOSATypeError except results from coercion.
  202.     */
  203.  
  204. enum {
  205.     errOSACantCoerce            = errAECoercionFail
  206. };
  207.  
  208. /* Signaled when an object is not found in a container */
  209.  
  210. enum {
  211.     errOSACantAccess            = errAENoSuchObject
  212. };
  213.  
  214. /*
  215.         Signaled when an object cannot be set in a container.  Same as 
  216.           AERegistry error errAEWriteDenied.
  217.     */
  218.  
  219. enum {
  220.     errOSACantAssign            = -10006
  221. };
  222.  
  223. /*
  224.         Signaled by user scripts or applications when no actual error code
  225.           is to be returned.  Simply means "an error has occurred".  Most useful
  226.           in conjunction with an error message from the application.
  227.     */
  228.  
  229. enum {
  230.     errOSAGeneralError            = -2700
  231. };
  232.  
  233. /* Signaled when there is an attempt to divide by zero */
  234.  
  235. enum {
  236.     errOSADivideByZero            = -2701
  237. };
  238.  
  239. /* Signaled when integer or real value is too large to be represented */
  240.  
  241. enum {
  242.     errOSANumericOverflow        = -2702
  243. };
  244.  
  245. /*
  246.         Signaled when application can't be launched or when it is remote and
  247.           program linking is not enabled.
  248.     */
  249.  
  250. enum {
  251.     errOSACantLaunch            = -2703
  252. };
  253.  
  254. /* Signaled when an application can't respond to AppleEvents */
  255.  
  256. enum {
  257.     errOSAAppNotHighLevelEventAware = -2704
  258. };
  259.  
  260. /* Signaled when an application's terminology resource is not readable */
  261.  
  262. enum {
  263.     errOSACorruptTerminology    = -2705
  264. };
  265.  
  266. /* Signaled when the runtime stack overflows */
  267.  
  268. enum {
  269.     errOSAStackOverflow            = -2706
  270. };
  271.  
  272. /* Signaled when a runtime internal data structure overflows */
  273.  
  274. enum {
  275.     errOSAInternalTableOverflow    = -2707
  276. };
  277.  
  278. /*
  279.         Signaled when an intrinsic limitation is exceeded for the size of 
  280.           a value or data structure.
  281.     */
  282.  
  283. enum {
  284.     errOSADataBlockTooLarge        = -2708
  285. };
  286.  
  287.  
  288. enum {
  289.     errOSACantGetTerminology    = -2709
  290. };
  291.  
  292.  
  293. enum {
  294.     errOSACantCreate            = -2710
  295. };
  296.  
  297. /*        Component-specific dynamic script errors:
  298.  
  299.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  300.     (Note that error codes from different scripting components in this range will
  301.     overlap.)
  302. */
  303. /*        Static errors:
  304.  
  305.     These errors comprise what are commonly thought of as parse and compile-
  306.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  307.     of these may also occur at runtime.
  308. */
  309.  
  310. /* Signaled when data was not the right type and coercion is not allowed */
  311.  
  312. enum {
  313.     errOSATypeError                = errAEWrongDataType
  314. };
  315.  
  316. /* Signaled when a message was sent to an object that didn't handle it */
  317.  
  318. enum {
  319.     OSAMessageNotUnderstood        = errAEEventNotHandled
  320. };
  321.  
  322. /*
  323.         Signaled when a function to be returned doesn't exist.  (Probably only
  324.           useful in languages with first-class functions that distinguish between
  325.           functions and other values (two name spaces). This is different from
  326.           errOSAMessageNotUnderstood, which may be signaled when the method is
  327.           invoked.
  328.     */
  329.  
  330. enum {
  331.     OSAUndefinedHandler            = errAEHandlerNotFound
  332. };
  333.  
  334. /* Signaled when a container can never have the requested object */
  335.  
  336. enum {
  337.     OSAIllegalAccess            = errAEAccessorNotFound
  338. };
  339.  
  340. /* Signaled when index was out of range. Specialization of errOSACantAccess. */
  341.  
  342. enum {
  343.     OSAIllegalIndex                = errAEIllegalIndex
  344. };
  345.  
  346. /* Signaled when a range is screwy. Specialization of errOSACantAccess. */
  347.  
  348. enum {
  349.     OSAIllegalRange                = errAEImpossibleRange
  350. };
  351.  
  352. /*
  353.         Signaled when an object can never be set in a container.  Same as 
  354.           AERegistry error errAENotModifiable.
  355.     */
  356.  
  357. enum {
  358.     OSAIllegalAssign            = -10003
  359. };
  360.  
  361. /*
  362.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  363.          "<this> can't go after <that>").
  364.     */
  365.  
  366. enum {
  367.     OSASyntaxError                = -2740
  368. };
  369.  
  370. /*
  371.         Signaled when another form of syntax was expected. (e.g. "expected
  372.           a <type> but found <this>").
  373.     */
  374.  
  375. enum {
  376.     OSASyntaxTypeError            = -2741
  377. };
  378.  
  379. /* Signaled when a name or number is too long to be parsed */
  380.  
  381. enum {
  382.     OSATokenTooLong                = -2742
  383. };
  384.  
  385. /*
  386.         Signaled when a parameter is missing for a function invocation.  Note
  387.           that in some languages, this error may occur at runtime.
  388.     */
  389.  
  390. enum {
  391.     OSAMissingParameter            = errAEDescNotFound
  392. };
  393.  
  394. /*
  395.         Signaled when function is called with the wrong number of parameters,
  396.           or a parameter pattern cannot be matched.
  397.     */
  398.  
  399. enum {
  400.     OSAParameterMismatch        = errAEWrongNumberArgs
  401. };
  402.  
  403. /*
  404.         Signaled when a formal parameter, local variable, or instance variable
  405.           is specified more than once.
  406.     */
  407.  
  408. enum {
  409.     OSADuplicateParameter        = -2750
  410. };
  411.  
  412. /*
  413.         Signaled when a formal parameter, local variable, or instance variable
  414.           is specified more than once.
  415.     */
  416.  
  417. enum {
  418.     OSADuplicateProperty        = -2751
  419. };
  420.  
  421. /*
  422.         Signaled when more than one handler is defined with the same name in 
  423.           a scope where the language doesn't allow it.
  424.     */
  425.  
  426. enum {
  427.     OSADuplicateHandler            = -2752
  428. };
  429.  
  430. /* Signaled when a variable is accessed that has no value */
  431.  
  432. enum {
  433.     OSAUndefinedVariable        = -2753
  434. };
  435.  
  436. /*
  437.         Signaled when a variable is declared inconsistently in the same scope,
  438.           such as both local and global.
  439.     */
  440.  
  441. enum {
  442.     OSAInconsistentDeclarations    = -2754
  443. };
  444.  
  445. /*
  446.         Signaled when illegal control flow occurs in an application (no catcher
  447.           for throw, non-lexical loop exit, etc.).
  448.     */
  449.  
  450. enum {
  451.     OSAControlFlowError            = -2755
  452. };
  453.  
  454. /*        Component-specific static script errors:
  455.  
  456.     The range -2760 thru -2779 is reserved for component-specific parsing and
  457.     compile-time errors. (Note that error codes from different scripting
  458.     components in this range will overlap.)
  459. */
  460. /*        Dialect-specific script errors:
  461.  
  462.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  463.     scripting components that support dialects. (Note that error codes from
  464.     different scripting components in this range will overlap, as well as error
  465.     codes from different dialects in the same scripting component.)
  466. */
  467. /**************************************************************************
  468.     OSA Interface Descriptions
  469. **************************************************************************
  470.     The OSA Interface is broken down into a required interface, and several
  471.     optional interfaces to support additional functionality.  A given scripting
  472.     component may choose to support only some of the optional interfaces in
  473.     addition to the basic interface.  The OSA Component Flags may be used to 
  474.     query the Component Manager to find a scripting component with a particular
  475.     capability, or determine if a particular scripting component supports a 
  476.     particular capability.
  477. **************************************************************************/
  478. /* OSA Component Flags: */
  479.  
  480. enum {
  481.     kOSASupportsCompiling        = 0x0002,
  482.     kOSASupportsGetSource        = 0x0004,
  483.     kOSASupportsAECoercion        = 0x0008,
  484.     kOSASupportsAESending        = 0x0010,
  485.     kOSASupportsRecording        = 0x0020,
  486.     kOSASupportsConvenience        = 0x0040,
  487.     kOSASupportsDialects        = 0x0080,
  488.     kOSASupportsEventHandling    = 0x0100
  489. };
  490.  
  491. /* Component Selectors: */
  492.  
  493. enum {
  494.     kOSASelectLoad                = 0x0001,
  495.     kOSASelectStore                = 0x0002,
  496.     kOSASelectExecute            = 0x0003,
  497.     kOSASelectDisplay            = 0x0004,
  498.     kOSASelectScriptError        = 0x0005,
  499.     kOSASelectDispose            = 0x0006,
  500.     kOSASelectSetScriptInfo        = 0x0007,
  501.     kOSASelectGetScriptInfo        = 0x0008,
  502.     kOSASelectSetActiveProc        = 0x0009,
  503.     kOSASelectGetActiveProc        = 0x000A
  504. };
  505.  
  506. /* Compiling: */
  507.  
  508. enum {
  509.     kOSASelectScriptingComponentName = 0x0102,
  510.     kOSASelectCompile            = 0x0103,
  511.     kOSASelectCopyID            = 0x0104
  512. };
  513.  
  514. /* GetSource: */
  515.  
  516. enum {
  517.     kOSASelectGetSource            = 0x0201
  518. };
  519.  
  520. /* AECoercion: */
  521.  
  522. enum {
  523.     kOSASelectCoerceFromDesc    = 0x0301,
  524.     kOSASelectCoerceToDesc        = 0x0302
  525. };
  526.  
  527. /* AESending: */
  528.  
  529. enum {
  530.     kOSASelectSetSendProc        = 0x0401,
  531.     kOSASelectGetSendProc        = 0x0402,
  532.     kOSASelectSetCreateProc        = 0x0403,
  533.     kOSASelectGetCreateProc        = 0x0404,
  534.     kOSASelectSetDefaultTarget    = 0x0405
  535. };
  536.  
  537. /* Recording: */
  538.  
  539. enum {
  540.     kOSASelectStartRecording    = 0x0501,
  541.     kOSASelectStopRecording        = 0x0502
  542. };
  543.  
  544. /* Convenience: */
  545.  
  546. enum {
  547.     kOSASelectLoadExecute        = 0x0601,
  548.     kOSASelectCompileExecute    = 0x0602,
  549.     kOSASelectDoScript            = 0x0603
  550. };
  551.  
  552. /* Dialects: */
  553.  
  554. enum {
  555.     kOSASelectSetCurrentDialect    = 0x0701,
  556.     kOSASelectGetCurrentDialect    = 0x0702,
  557.     kOSASelectAvailableDialects    = 0x0703,
  558.     kOSASelectGetDialectInfo    = 0x0704,
  559.     kOSASelectAvailableDialectCodeList = 0x0705
  560. };
  561.  
  562. /* Event Handling: */
  563.  
  564. enum {
  565.     kOSASelectSetResumeDispatchProc = 0x0801,
  566.     kOSASelectGetResumeDispatchProc = 0x0802,
  567.     kOSASelectExecuteEvent        = 0x0803,
  568.     kOSASelectDoEvent            = 0x0804,
  569.     kOSASelectMakeContext        = 0x0805
  570. };
  571.  
  572.  
  573. /* scripting component specific selectors are added beginning with this value  */
  574.  
  575. enum {
  576.     kOSASelectComponentSpecificStart = 0x1001
  577. };
  578.  
  579.  
  580. /*        Mode Flags:
  581.  
  582.     Warning: These should not conflict with the AESend mode flags in
  583.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  584. */
  585.  
  586. /*
  587.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  588.           instruct the scripting component to not retain the "source" of an
  589.           expression.  This will cause the OSAGetSource call to return the error
  590.           errOSASourceNotAvailable if used.  However, some scripting components
  591.           may not retain the source anyway.  This is mainly used when either space
  592.           efficiency is desired, or a script is to be "locked" so that its
  593.           implementation may not be viewed.
  594.     */
  595.  
  596. enum {
  597.     kOSAModePreventGetSource    = 0x00000001
  598. };
  599.  
  600. /*
  601.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  602.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  603.           indicate whether or not the script may interact with the user, switch
  604.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  605.           corresponding AESend mode supplied.
  606.     */
  607.  
  608. enum {
  609.     kOSAModeNeverInteract        = kAENeverInteract,
  610.     kOSAModeCanInteract            = kAECanInteract,
  611.     kOSAModeAlwaysInteract        = kAEAlwaysInteract,
  612.     kOSAModeDontReconnect        = kAEDontReconnect
  613. };
  614.  
  615. /*
  616.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  617.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  618.           indicate whether or not AppleEvents should be sent with the
  619.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  620.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  621.           provide a more convenient default, i.e. not supplying any mode
  622.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  623.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  624.           without kAECanSwitchLayer.
  625.     */
  626.  
  627. enum {
  628.     kOSAModeCantSwitchLayer        = 0x00000040
  629. };
  630.  
  631. /*
  632.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  633.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  634.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  635.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  636.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  637.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  638.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  639.           cause AESend to be called without kAEDontRecord.
  640.     */
  641.  
  642. enum {
  643.     kOSAModeDoRecord            = 0x00001000
  644. };
  645.  
  646. /*
  647.         This is a mode flag for OSACompile that indicates that a context should
  648.           be created as the result of compilation. All handler definitions are
  649.           inserted into the new context, and variables are initialized by
  650.           evaluating their initial values in a null context (i.e. they must be
  651.           constant expressions).
  652.     */
  653.  
  654. enum {
  655.     kOSAModeCompileIntoContext    = 0x00000002
  656. };
  657.  
  658. /*
  659.         This is a mode flag for OSACompile that indicates that the previous
  660.           script ID (input to OSACompile) should be augmented with any new
  661.           definitions in the sourceData rather than replaced with a new script.
  662.           This means that the previous script ID must designate a context.
  663.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  664.           to be implicitly used, causing any new definitions to be initialized
  665.           in a null context.
  666.     */
  667.  
  668. enum {
  669.     kOSAModeAugmentContext        = 0x00000004
  670. };
  671.  
  672. /*
  673.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  674.           that output only need be human-readable, not re-compilable by OSACompile.
  675.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  676.           off of string values, long lists may have elipses, etc.
  677.     */
  678.  
  679. enum {
  680.     kOSAModeDisplayForHumans    = 0x00000008
  681. };
  682.  
  683. /*
  684.         This mode flag may be passed to OSAStore in the case where the scriptID
  685.           is a context.  This causes the context to be saved, but not the context's
  686.           parent context.  When the stored context is loaded back in, the parent
  687.           will be kOSANullScript.
  688.     */
  689.  
  690. enum {
  691.     kOSAModeDontStoreParent        = 0x00010000
  692. };
  693.  
  694. /*
  695.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  696.           be dispatched to the direct object of the event. The direct object (or
  697.           subject attribute if the direct object is a non-object specifier) will
  698.           be resolved, and the resulting script object will be the recipient of
  699.           the message. The context argument to OSAExecuteEvent will serve as the
  700.           root of the lookup/resolution process.
  701.     */
  702.  
  703. enum {
  704.     kOSAModeDispatchToDirectObject = 0x00020000
  705. };
  706.  
  707. /*
  708.         This mode flag may be passed to OSAExecuteEvent to indicate that
  709.           components do not have to get the data of object specifier arguments.
  710.     */
  711.  
  712. enum {
  713.     kOSAModeDontGetDataForArguments = 0x00040000
  714. };
  715.  
  716. /**************************************************************************
  717.     OSA Basic Scripting Interface
  718. **************************************************************************
  719.     Scripting components must at least support the Basic Scripting interface.
  720. **************************************************************************/
  721. /*        Loading and Storing Scripts:
  722.  
  723.     These routines allow scripts to be loaded and stored in their internal
  724.     (possibly compiled, non-text) representation.
  725. */
  726.  
  727. /* Resource type for scripts */
  728.  
  729. enum {
  730.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype
  731. };
  732.  
  733. /*
  734.         Default type given to OSAStore which creates "generic" loadable script
  735.           data descriptors.
  736.     */
  737.  
  738. enum {
  739.     typeOSAGenericStorage        = kOSAScriptResourceType
  740. };
  741.  
  742. EXTERN_API( OSAError )
  743. OSALoad                            (ComponentInstance         scriptingComponent,
  744.                                  const AEDesc *            scriptData,
  745.                                  long                     modeFlags,
  746.                                  OSAID *                resultingScriptID)                    FIVEWORDINLINE(0x2F3C, 0x000C, 0x0001, 0x7000, 0xA82A);
  747.  
  748. /*
  749.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  750.     
  751.         Errors:
  752.             badComponentInstance        invalid scripting component instance
  753.             errOSASystemError
  754.             errOSABadStorageType:        scriptData not for this scripting component
  755.             errOSACorruptData:            data seems to be corrupt
  756.             errOSADataFormatObsolete    script data format is no longer supported
  757.             errOSADataFormatTooNew        script data format is from a newer version
  758.         
  759.         ModeFlags:
  760.             kOSAModePreventGetSource
  761.     */
  762. EXTERN_API( OSAError )
  763. OSAStore                        (ComponentInstance         scriptingComponent,
  764.                                  OSAID                     scriptID,
  765.                                  DescType                 desiredType,
  766.                                  long                     modeFlags,
  767.                                  AEDesc *                resultingScriptData)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0002, 0x7000, 0xA82A);
  768.  
  769. /*
  770.         OSAComponentFunctionInline(kOSASelectStore, 16);
  771.     
  772.         Errors:
  773.             badComponentInstance    invalid scripting component instance
  774.             errOSASystemError
  775.             errOSAInvalidID
  776.             errOSABadStorageType:    desiredType not for this scripting component
  777.         
  778.         ModeFlags:
  779.             kOSAModePreventGetSource
  780.             kOSAModeDontStoreParent
  781.     */
  782. /* Executing Scripts: */
  783. EXTERN_API( OSAError )
  784. OSAExecute                        (ComponentInstance         scriptingComponent,
  785.                                  OSAID                     compiledScriptID,
  786.                                  OSAID                     contextID,
  787.                                  long                     modeFlags,
  788.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0003, 0x7000, 0xA82A);
  789.  
  790. /*
  791.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  792.         This call runs a script.  The contextID represents the environment
  793.         with which global variables in the script are resolved.  The constant
  794.         kOSANullScript may be used for the contextID if the application wishes
  795.         to not deal with context directly (a default one is associated with each
  796.         scripting component instance).  The resultingScriptValueID is the 
  797.         result of evaluation, and contains a value which may be displayed using
  798.         the OSAGetSource call.  The modeFlags convey scripting component
  799.         specific information.
  800.     
  801.         Errors:
  802.             badComponentInstance    invalid scripting component instance
  803.             errOSASystemError
  804.             errOSAInvalidID
  805.             errOSAScriptError:        the executing script got an error
  806.     
  807.         ModeFlags:
  808.             kOSAModeNeverInteract
  809.             kOSAModeCanInteract
  810.             kOSAModeAlwaysInteract
  811.             kOSAModeCantSwitchLayer
  812.             kOSAModeDontReconnect
  813.             kOSAModeDoRecord
  814.     */
  815. /* Displaying results: */
  816. EXTERN_API( OSAError )
  817. OSADisplay                        (ComponentInstance         scriptingComponent,
  818.                                  OSAID                     scriptValueID,
  819.                                  DescType                 desiredType,
  820.                                  long                     modeFlags,
  821.                                  AEDesc *                resultingText)                        FIVEWORDINLINE(0x2F3C, 0x0010, 0x0004, 0x7000, 0xA82A);
  822.  
  823. /*
  824.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  825.         This call is used to convert results (script value IDs) into displayable
  826.         text. The desiredType should be at least typeChar, and modeFlags are
  827.         scripting system specific flags to control the formatting of the
  828.         resulting text. This call differs from OSAGetSource in that (1) it
  829.         always produces at least typeChar, (2) is only works on script values,
  830.         (3) it may display it's output in non-compilable form (e.g. without
  831.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  832.         (4) it is required by the basic scripting interface.
  833.     
  834.         Errors:
  835.             badComponentInstance    invalid scripting component instance
  836.             errOSASystemError
  837.             errOSAInvalidID
  838.             errAECoercionFail:        desiredType not supported by scripting component
  839.     
  840.         ModeFlags:
  841.             kOSAModeDisplayForHumans
  842.     */
  843. /* Getting Error Information: */
  844. EXTERN_API( OSAError )
  845. OSAScriptError                    (ComponentInstance         scriptingComponent,
  846.                                  OSType                 selector,
  847.                                  DescType                 desiredType,
  848.                                  AEDesc *                resultingErrorDescription)            FIVEWORDINLINE(0x2F3C, 0x000C, 0x0005, 0x7000, 0xA82A);
  849.  
  850. /*
  851.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  852.         Whenever script execution returns errOSAExecutionError, this routine
  853.         may be used to get information about that error.  The selector describes
  854.         the type of information desired about the error (various selectors are
  855.         listed below).  The desiredType indicates the data type of the result
  856.         desired for that selector.
  857.     
  858.         Errors:
  859.             badComponentInstance    invalid scripting component instance
  860.             errOSASystemError
  861.             errOSABadSelector:        selector not supported by scripting component
  862.             errAECoercionFail:        desiredType not supported by scripting component
  863.     */
  864. /* OSAScriptError selectors: */
  865. /*
  866.         This selector is used to determine the error number of a script error.
  867.         These error numbers may be either system error numbers, or error numbers
  868.         that are scripting component specific.
  869.         Required desiredTypes:    
  870.               typeShortInteger
  871.     */
  872.  
  873. enum {
  874.     kOSAErrorNumber                = keyErrorNumber
  875. };
  876.  
  877. /*
  878.         This selector is used to determine the full error message associated
  879.         with the error number.  It should include the name of the application
  880.         which caused the error, as well as the specific error that occurred.
  881.         This selector is sufficient for simple error reporting (but see
  882.         kOSAErrorBriefMessage, below).
  883.         Required desiredTypes:
  884.             typeChar                    error message string
  885.     */
  886.  
  887. enum {
  888.     kOSAErrorMessage            = keyErrorString
  889. };
  890.  
  891. /*
  892.         This selector is used to determine a brief error message associated with
  893.         the error number.  This message and should not mention the name of the
  894.         application which caused the error, any partial results or offending
  895.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  896.         kOSAErrorOffendingObject, below).
  897.         Required desiredTypes:
  898.               typeChar                    brief error message string
  899.     */
  900. /*  0x65727262  */
  901.  
  902. enum {
  903.     kOSAErrorBriefMessage        = FOUR_CHAR_CODE('errb')
  904. };
  905.  
  906. /*
  907.         This selector is used to determine which application actually got the
  908.         error (if it was the result of an AESend), or the current application
  909.         if ....
  910.         Required desiredTypes:
  911.               typeProcessSerialNumber        PSN of the errant application
  912.               typeChar                    name of the errant application
  913.     */
  914. /*  0x65726170  */
  915.  
  916. enum {
  917.     kOSAErrorApp                = FOUR_CHAR_CODE('erap')
  918. };
  919.  
  920. /*
  921.         This selector is used to determine any partial result returned by an 
  922.         operation. If an AESend call failed, but a partial result was returned,
  923.         then the partial result may be returned as an AEDesc.
  924.         Required desiredTypes:
  925.               typeBest                    AEDesc of any partial result
  926.     */
  927. /*  0x70746c72   */
  928.  
  929. enum {
  930.     kOSAErrorPartialResult        = FOUR_CHAR_CODE('ptlr')
  931. };
  932.  
  933. /*
  934.         This selector is used to determine any object which caused the error
  935.         that may have been indicated by an application.  The result is an 
  936.         AEDesc.
  937.         Required desiredTypes:
  938.               typeBest                    AEDesc of any offending object
  939.     */
  940. /*  0x65726f62   */
  941.  
  942. enum {
  943.     kOSAErrorOffendingObject    = FOUR_CHAR_CODE('erob')
  944. };
  945.  
  946. /*
  947.         This selector is used to determine the type expected by a coercion 
  948.         operation if a type error occurred.
  949.     */
  950. /*  0x65727274   */
  951.  
  952. enum {
  953.     kOSAErrorExpectedType        = FOUR_CHAR_CODE('errt')
  954. };
  955.  
  956. /*
  957.         This selector is used to determine the source text range (start and 
  958.         end positions) of where the error occurred.
  959.         Required desiredTypes:
  960.               typeOSAErrorRange
  961.     */
  962. /*  0x65726e67  */
  963.  
  964. enum {
  965.     kOSAErrorRange                = FOUR_CHAR_CODE('erng')
  966. };
  967.  
  968. /*
  969.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  970.         of type short.
  971.     */
  972. /*  0x65726e67   */
  973.  
  974. enum {
  975.     typeOSAErrorRange            = FOUR_CHAR_CODE('erng')
  976. };
  977.  
  978. /* Field of a typeOSAErrorRange record of typeShortInteger */
  979. /*  0x73726373    */
  980.  
  981. enum {
  982.     keyOSASourceStart            = FOUR_CHAR_CODE('srcs')
  983. };
  984.  
  985. /* Field of a typeOSAErrorRange record of typeShortInteger */
  986. /*  0x73726365   */
  987.  
  988. enum {
  989.     keyOSASourceEnd                = FOUR_CHAR_CODE('srce')
  990. };
  991.  
  992. /* Disposing Script IDs: */
  993. EXTERN_API( OSAError )
  994. OSADispose                        (ComponentInstance         scriptingComponent,
  995.                                  OSAID                     scriptID)                            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0006, 0x7000, 0xA82A);
  996.  
  997. /*
  998.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  999.         Disposes a script or context.
  1000.     
  1001.         Errors:
  1002.             badComponentInstance    invalid scripting component instance
  1003.             errOSASystemError
  1004.             errOSAInvalidID
  1005.     */
  1006. /* Getting and Setting Script Information: */
  1007. EXTERN_API( OSAError )
  1008. OSASetScriptInfo                (ComponentInstance         scriptingComponent,
  1009.                                  OSAID                     scriptID,
  1010.                                  OSType                 selector,
  1011.                                  long                     value)                                FIVEWORDINLINE(0x2F3C, 0x000C, 0x0007, 0x7000, 0xA82A);
  1012.  
  1013. /*
  1014.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  1015.     
  1016.         Errors:
  1017.             badComponentInstance    invalid scripting component instance
  1018.             errOSASystemError
  1019.             errOSAInvalidID
  1020.             errOSABadSelector:        selector not supported by scripting component
  1021.                                     or selector not for this scriptID
  1022.     */
  1023. EXTERN_API( OSAError )
  1024. OSAGetScriptInfo                (ComponentInstance         scriptingComponent,
  1025.                                  OSAID                     scriptID,
  1026.                                  OSType                 selector,
  1027.                                  long *                    result)                                FIVEWORDINLINE(0x2F3C, 0x000C, 0x0008, 0x7000, 0xA82A);
  1028.  
  1029. /*
  1030.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  1031.     
  1032.         Errors:
  1033.             badComponentInstance    invalid scripting component instance
  1034.             errOSASystemError
  1035.             errOSAInvalidID
  1036.             errOSABadSelector:        selector not supported by scripting component
  1037.                                     or selector not for this scriptID
  1038.     */
  1039. /* Manipulating the ActiveProc:
  1040.  
  1041.     Scripting systems will supply default values for these procedures if they
  1042.     are not set by the client:
  1043. */
  1044. typedef CALLBACK_API( OSErr , OSAActiveProcPtr )(long refCon);
  1045. typedef STACK_UPP_TYPE(OSAActiveProcPtr)                         OSAActiveUPP;
  1046. enum { uppOSAActiveProcInfo = 0x000000E0 };                     /* pascal 2_bytes Func(4_bytes) */
  1047. #define NewOSAActiveProc(userRoutine)                             (OSAActiveUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSAActiveProcInfo, GetCurrentArchitecture())
  1048. #define CallOSAActiveProc(userRoutine, refCon)                     CALL_ONE_PARAMETER_UPP((userRoutine), uppOSAActiveProcInfo, (refCon))
  1049. EXTERN_API( OSAError )
  1050. OSASetActiveProc                (ComponentInstance         scriptingComponent,
  1051.                                  OSAActiveUPP             activeProc,
  1052.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0009, 0x7000, 0xA82A);
  1053.  
  1054. /*
  1055.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  1056.         If activeProc is nil, the default activeProc is used.
  1057.     
  1058.         Errors:
  1059.             badComponentInstance    invalid scripting component instance
  1060.             errOSASystemError
  1061.     */
  1062. EXTERN_API( OSAError )
  1063. OSAGetActiveProc                (ComponentInstance         scriptingComponent,
  1064.                                  OSAActiveUPP *            activeProc,
  1065.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x000A, 0x7000, 0xA82A);
  1066.  
  1067. /*
  1068.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  1069.     
  1070.         Errors:
  1071.             badComponentInstance    invalid scripting component instance
  1072.             errOSASystemError
  1073.     */
  1074. /**************************************************************************
  1075.     OSA Optional Compiling Interface
  1076. **************************************************************************
  1077.     Scripting components that support the Compiling interface have the 
  1078.     kOSASupportsCompiling bit set in it's ComponentDescription.
  1079. **************************************************************************/
  1080. EXTERN_API( OSAError )
  1081. OSAScriptingComponentName        (ComponentInstance         scriptingComponent,
  1082.                                  AEDesc *                resultingScriptingComponentName)    FIVEWORDINLINE(0x2F3C, 0x0004, 0x0102, 0x7000, 0xA82A);
  1083.  
  1084. /*
  1085.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  1086.         Given a scripting component, this routine returns the name of that
  1087.         scripting component in a type that is coercable to text (typeChar).
  1088.         The generic scripting component returns the name of the default
  1089.         scripting component.  This name should be sufficient to convey to the
  1090.         user the kind of script (syntax) he is expected to write.
  1091.     
  1092.         Errors:
  1093.             badComponentInstance    invalid scripting component instance
  1094.             errOSASystemError
  1095.     */
  1096. EXTERN_API( OSAError )
  1097. OSACompile                        (ComponentInstance         scriptingComponent,
  1098.                                  const AEDesc *            sourceData,
  1099.                                  long                     modeFlags,
  1100.                                  OSAID *                previousAndResultingScriptID)        FIVEWORDINLINE(0x2F3C, 0x000C, 0x0103, 0x7000, 0xA82A);
  1101.  
  1102. /*
  1103.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  1104.         Coerces input desc (possibly text) into a script's internal format.
  1105.         Once compiled, the script is ready to run.  The modeFlags convey
  1106.         scripting component specific information.  The previous script ID
  1107.         (result parameter) is made to refer to the newly compiled script,
  1108.         unless it was originally kOSANullScript.  In this case a new script
  1109.         ID is created and used.
  1110.     
  1111.         Errors:
  1112.             badComponentInstance    invalid scripting component instance
  1113.             errOSASystemError
  1114.             errAECoercionFail:        sourceData is not compilable
  1115.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1116.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1117.                                     valid on input
  1118.     
  1119.         ModeFlags:
  1120.             kOSAModePreventGetSource
  1121.             kOSAModeCompileIntoContext
  1122.             kOSAModeAugmentContext
  1123.             kOSAModeNeverInteract
  1124.             kOSAModeCanInteract
  1125.             kOSAModeAlwaysInteract
  1126.             kOSAModeCantSwitchLayer
  1127.             kOSAModeDontReconnect
  1128.             kOSAModeDoRecord
  1129.     */
  1130. EXTERN_API( OSAError )
  1131. OSACopyID                        (ComponentInstance         scriptingComponent,
  1132.                                  OSAID                     fromID,
  1133.                                  OSAID *                toID)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0104, 0x7000, 0xA82A);
  1134.  
  1135. /*
  1136.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  1137.         If toID is a reference to kOSANullScript then it is updated to have a
  1138.         new scriptID value.  This call can be used to perform undo or revert
  1139.         operations on scripts. 
  1140.     
  1141.         Errors:
  1142.             badComponentInstance    invalid scripting component instance
  1143.             errOSASystemError
  1144.             errOSAInvalidID
  1145.     */
  1146. /**************************************************************************
  1147.     OSA Optional GetSource Interface
  1148. **************************************************************************
  1149.     Scripting components that support the GetSource interface have the 
  1150.     kOSASupportsGetSource bit set in it's ComponentDescription.
  1151. **************************************************************************/
  1152. EXTERN_API( OSAError )
  1153. OSAGetSource                    (ComponentInstance         scriptingComponent,
  1154.                                  OSAID                     scriptID,
  1155.                                  DescType                 desiredType,
  1156.                                  AEDesc *                resultingSourceData)                FIVEWORDINLINE(0x2F3C, 0x000C, 0x0201, 0x7000, 0xA82A);
  1157.  
  1158. /*
  1159.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  1160.         This routine causes a compiled script to be output in a form (possibly
  1161.         text) such that it is suitable to be passed back to OSACompile.
  1162.  
  1163.         Errors:
  1164.             badComponentInstance    invalid scripting component instance
  1165.             errOSASystemError
  1166.             errOSAInvalidID
  1167.             errOSASourceNotAvailable    can't get source for this scriptID
  1168.     */
  1169. /**************************************************************************
  1170.     OSA Optional AECoercion Interface
  1171. **************************************************************************
  1172.     Scripting components that support the AECoercion interface have the 
  1173.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  1174. **************************************************************************/
  1175. EXTERN_API( OSAError )
  1176. OSACoerceFromDesc                (ComponentInstance         scriptingComponent,
  1177.                                  const AEDesc *            scriptData,
  1178.                                  long                     modeFlags,
  1179.                                  OSAID *                resultingScriptID)                    FIVEWORDINLINE(0x2F3C, 0x000C, 0x0301, 0x7000, 0xA82A);
  1180.  
  1181. /*
  1182.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1183.         This routine causes script data to be coerced into a script value.
  1184.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  1185.         compiled script ID (mode flags for OSACompile may be used in this case).
  1186.         Other scriptData descriptors create script value IDs.
  1187.     
  1188.         Errors:
  1189.             badComponentInstance    invalid scripting component instance
  1190.             errOSASystemError
  1191.     
  1192.         ModeFlags:
  1193.             kOSAModePreventGetSource
  1194.             kOSAModeCompileIntoContext
  1195.             kOSAModeNeverInteract
  1196.             kOSAModeCanInteract
  1197.             kOSAModeAlwaysInteract
  1198.             kOSAModeCantSwitchLayer
  1199.             kOSAModeDontReconnect
  1200.             kOSAModeDoRecord
  1201.     */
  1202. EXTERN_API( OSAError )
  1203. OSACoerceToDesc                    (ComponentInstance         scriptingComponent,
  1204.                                  OSAID                     scriptID,
  1205.                                  DescType                 desiredType,
  1206.                                  long                     modeFlags,
  1207.                                  AEDesc *                result)                                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0302, 0x7000, 0xA82A);
  1208.  
  1209. /*
  1210.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1211.         This routine causes a script value to be coerced into any desired form.
  1212.         If the scriptID denotes a compiled script, then it may be coerced to 
  1213.         typeAppleEvent.
  1214.     
  1215.         Errors:
  1216.             badComponentInstance    invalid scripting component instance
  1217.             errOSASystemError
  1218.             errOSAInvalidID
  1219.     */
  1220. /**************************************************************************
  1221.     OSA Optional AESending Interface
  1222. **************************************************************************
  1223.     Scripting components that support the AESending interface have the 
  1224.     kOSASupportsAESending bit set in it's ComponentDescription.
  1225. **************************************************************************/
  1226. /*
  1227.     Scripting systems will supply default values for these procedures if they
  1228.     are not set by the client:
  1229. */
  1230. EXTERN_API( OSAError )
  1231. OSASetSendProc                    (ComponentInstance         scriptingComponent,
  1232.                                  OSASendUPP             sendProc,
  1233.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0401, 0x7000, 0xA82A);
  1234.  
  1235. /*
  1236.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1237.         If sendProc is nil, the default sendProc is used.
  1238.     
  1239.         Errors:
  1240.             badComponentInstance    invalid scripting component instance
  1241.             errOSASystemError
  1242.     */
  1243. EXTERN_API( OSAError )
  1244. OSAGetSendProc                    (ComponentInstance         scriptingComponent,
  1245.                                  OSASendUPP *            sendProc,
  1246.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0402, 0x7000, 0xA82A);
  1247.  
  1248. /*
  1249.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1250.     
  1251.         Errors:
  1252.             badComponentInstance    invalid scripting component instance
  1253.             errOSASystemError
  1254.     */
  1255. EXTERN_API( OSAError )
  1256. OSASetCreateProc                (ComponentInstance         scriptingComponent,
  1257.                                  OSACreateAppleEventUPP  createProc,
  1258.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0403, 0x7000, 0xA82A);
  1259.  
  1260. /*
  1261.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1262.         If createProc is nil, the default createProc is used.
  1263.     
  1264.         Errors:
  1265.             badComponentInstance    invalid scripting component instance
  1266.             errOSASystemError
  1267.     */
  1268. EXTERN_API( OSAError )
  1269. OSAGetCreateProc                (ComponentInstance         scriptingComponent,
  1270.                                  OSACreateAppleEventUPP * createProc,
  1271.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0404, 0x7000, 0xA82A);
  1272.  
  1273. /*
  1274.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1275.     
  1276.         Errors:
  1277.             badComponentInstance    invalid scripting component instance
  1278.             errOSASystemError
  1279.     */
  1280. EXTERN_API( OSAError )
  1281. OSASetDefaultTarget                (ComponentInstance         scriptingComponent,
  1282.                                  const AEAddressDesc *    target)                                FIVEWORDINLINE(0x2F3C, 0x0004, 0x0405, 0x7000, 0xA82A);
  1283.  
  1284. /*
  1285.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1286.         This routine sets the default target application for AE sending.
  1287.         It also establishes the default target from which terminologies come.
  1288.         It is effectively like having an AppleScript "tell" statement around
  1289.         the entire program.  If this routine is not called, or if the target 
  1290.         is a null AEDesc, then the current application is the default target.
  1291.     
  1292.         Errors:
  1293.             badComponentInstance    invalid scripting component instance
  1294.             errOSASystemError
  1295.     */
  1296. /**************************************************************************
  1297.     OSA Optional Recording Interface
  1298. **************************************************************************
  1299.     Scripting components that support the Recording interface have the 
  1300.     kOSASupportsRecording bit set in it's ComponentDescription.
  1301. **************************************************************************/
  1302. EXTERN_API( OSAError )
  1303. OSAStartRecording                (ComponentInstance         scriptingComponent,
  1304.                                  OSAID *                compiledScriptToModifyID)            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0501, 0x7000, 0xA82A);
  1305.  
  1306. /*
  1307.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1308.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1309.         new script ID is created and returned.  If the current application has
  1310.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1311.         are sent to the application containing the text of each AppleEvent 
  1312.         recorded.
  1313.     
  1314.         Errors:
  1315.             badComponentInstance    invalid scripting component instance
  1316.             errOSASystemError
  1317.             errOSAInvalidID
  1318.             errOSARecordingIsAlreadyOn
  1319.     */
  1320. EXTERN_API( OSAError )
  1321. OSAStopRecording                (ComponentInstance         scriptingComponent,
  1322.                                  OSAID                     compiledScriptID)                    FIVEWORDINLINE(0x2F3C, 0x0004, 0x0502, 0x7000, 0xA82A);
  1323.  
  1324. /*
  1325.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1326.         If compiledScriptID is not being recorded into or recording is not
  1327.         currently on, no error is returned.
  1328.     
  1329.         Errors:
  1330.             badComponentInstance    invalid scripting component instance
  1331.             errOSASystemError
  1332.             errOSAInvalidID
  1333.     */
  1334. /**************************************************************************
  1335.     OSA Optional Convenience Interface
  1336. **************************************************************************
  1337.     Scripting components that support the Convenience interface have the 
  1338.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1339. **************************************************************************/
  1340. EXTERN_API( OSAError )
  1341. OSALoadExecute                    (ComponentInstance         scriptingComponent,
  1342.                                  const AEDesc *            scriptData,
  1343.                                  OSAID                     contextID,
  1344.                                  long                     modeFlags,
  1345.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0601, 0x7000, 0xA82A);
  1346.  
  1347. /*
  1348.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1349.         This routine is effectively equivalent to calling OSALoad followed by
  1350.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1351.         resulting value ID is retained.
  1352.     
  1353.         Errors:
  1354.             badComponentInstance        invalid scripting component instance
  1355.             errOSASystemError
  1356.             errOSABadStorageType:        scriptData not for this scripting component
  1357.             errOSACorruptData:            data seems to be corrupt
  1358.             errOSADataFormatObsolete    script data format is no longer supported
  1359.             errOSADataFormatTooNew        script data format is from a newer version
  1360.             errOSAInvalidID
  1361.             errOSAScriptError:            the executing script got an error
  1362.     
  1363.         ModeFlags:
  1364.             kOSAModeNeverInteract
  1365.             kOSAModeCanInteract
  1366.             kOSAModeAlwaysInteract
  1367.             kOSAModeCantSwitchLayer
  1368.             kOSAModeDontReconnect
  1369.             kOSAModeDoRecord
  1370.     */
  1371. EXTERN_API( OSAError )
  1372. OSACompileExecute                (ComponentInstance         scriptingComponent,
  1373.                                  const AEDesc *            sourceData,
  1374.                                  OSAID                     contextID,
  1375.                                  long                     modeFlags,
  1376.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0602, 0x7000, 0xA82A);
  1377.  
  1378. /*
  1379.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1380.         This routine is effectively equivalent to calling OSACompile followed by
  1381.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1382.         resulting value ID is retained.
  1383.     
  1384.         Errors:
  1385.             badComponentInstance    invalid scripting component instance
  1386.             errOSASystemError
  1387.             errAECoercionFail:        sourceData is not compilable
  1388.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1389.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1390.                                     valid on input
  1391.             errOSAScriptError:        the executing script got an error
  1392.     
  1393.         ModeFlags:
  1394.             kOSAModeNeverInteract
  1395.             kOSAModeCanInteract
  1396.             kOSAModeAlwaysInteract
  1397.             kOSAModeCantSwitchLayer
  1398.             kOSAModeDontReconnect
  1399.             kOSAModeDoRecord
  1400.     */
  1401. EXTERN_API( OSAError )
  1402. OSADoScript                        (ComponentInstance         scriptingComponent,
  1403.                                  const AEDesc *            sourceData,
  1404.                                  OSAID                     contextID,
  1405.                                  DescType                 desiredType,
  1406.                                  long                     modeFlags,
  1407.                                  AEDesc *                resultingText)                        FIVEWORDINLINE(0x2F3C, 0x0014, 0x0603, 0x7000, 0xA82A);
  1408.  
  1409. /*
  1410.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1411.         This routine is effectively equivalent to calling OSACompile followed by
  1412.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1413.         and the resulting value are is disposed.  Only the resultingText
  1414.         descriptor is retained.  If a script error occur during processing, the 
  1415.         resultingText gets the error message of the error, and errOSAScriptError
  1416.         is returned.  OSAScriptError may still be used to extract more 
  1417.         information about the particular error.
  1418.     
  1419.         Errors:
  1420.             badComponentInstance    invalid scripting component instance
  1421.             errOSASystemError
  1422.             errAECoercionFail:        sourceData is not compilable or 
  1423.                                     desiredType not supported by scripting component
  1424.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1425.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1426.                                     valid on input
  1427.             errOSAScriptError:        the executing script got an error
  1428.     
  1429.         ModeFlags:
  1430.             kOSAModeNeverInteract
  1431.             kOSAModeCanInteract
  1432.             kOSAModeAlwaysInteract
  1433.             kOSAModeCantSwitchLayer
  1434.             kOSAModeDontReconnect
  1435.             kOSAModeDoRecord
  1436.             kOSAModeDisplayForHumans
  1437.     */
  1438. /**************************************************************************
  1439.     OSA Optional Dialects Interface
  1440. **************************************************************************
  1441.     Scripting components that support the Dialects interface have the 
  1442.     kOSASupportsDialects bit set in it's ComponentDescription.
  1443. **************************************************************************/
  1444. /*
  1445.     These calls allows an scripting component that supports different dialects
  1446.     to dynamically switch between those dialects.  Although this interface is
  1447.     specified, the particular dialect codes are scripting component dependent.
  1448. */
  1449. EXTERN_API( OSAError )
  1450. OSASetCurrentDialect            (ComponentInstance         scriptingComponent,
  1451.                                  short                     dialectCode)                        FIVEWORDINLINE(0x2F3C, 0x0002, 0x0701, 0x7000, 0xA82A);
  1452.  
  1453. /*
  1454.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1455.     
  1456.         Errors:
  1457.             badComponentInstance    invalid scripting component instance
  1458.             errOSASystemError
  1459.             errOSANoSuchDialect:    invalid dialectCode
  1460.     */
  1461. EXTERN_API( OSAError )
  1462. OSAGetCurrentDialect            (ComponentInstance         scriptingComponent,
  1463.                                  short *                resultingDialectCode)                FIVEWORDINLINE(0x2F3C, 0x0004, 0x0702, 0x7000, 0xA82A);
  1464.  
  1465. /*
  1466.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1467.     
  1468.         Errors:
  1469.             badComponentInstance    invalid scripting component instance
  1470.             errOSASystemError
  1471.     */
  1472. EXTERN_API( OSAError )
  1473. OSAAvailableDialects            (ComponentInstance         scriptingComponent,
  1474.                                  AEDesc *                resultingDialectInfoList)            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0703, 0x7000, 0xA82A);
  1475.  
  1476. /*
  1477.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1478.         This call return an AEList containing information about each of the
  1479.         currently available dialects of a scripting component.  Each item
  1480.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1481.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1482.         keyOSADialectScriptCode.
  1483.     
  1484.         Errors:
  1485.             badComponentInstance    invalid scripting component instance
  1486.             errOSASystemError
  1487.     */
  1488. EXTERN_API( OSAError )
  1489. OSAGetDialectInfo                (ComponentInstance         scriptingComponent,
  1490.                                  short                     dialectCode,
  1491.                                  OSType                 selector,
  1492.                                  AEDesc *                resultingDialectInfo)                FIVEWORDINLINE(0x2F3C, 0x000A, 0x0704, 0x7000, 0xA82A);
  1493.  
  1494. /*
  1495.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1496.         This call gives information about the specified dialect of a scripting
  1497.         component. It returns an AEDesc whose type depends on the selector 
  1498.         specified. Available selectors are the same as the field keys for a
  1499.         dialect info record. The type of AEDesc returned is the same as the 
  1500.         type of the field that has same key as the selector.
  1501.     
  1502.         Errors:
  1503.             badComponentInstance    invalid scripting component instance
  1504.             errOSASystemError
  1505.              errOSABadSelector
  1506.             errOSANoSuchDialect:    invalid dialectCode
  1507.     */
  1508. EXTERN_API( OSAError )
  1509. OSAAvailableDialectCodeList        (ComponentInstance         scriptingComponent,
  1510.                                  AEDesc *                resultingDialectCodeList)            FIVEWORDINLINE(0x2F3C, 0x0004, 0x0705, 0x7000, 0xA82A);
  1511.  
  1512. /*
  1513.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1514.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1515.         and  OSAGetDialectInfo to get information on dialects.
  1516.         This call return an AEList containing dialect code for each of the
  1517.         currently available dialects of a scripting component. Each dialect
  1518.         code is a short integer of type typeShortInteger.
  1519.     
  1520.         Errors:
  1521.             badComponentInstance    invalid scripting component instance
  1522.             errOSASystemError
  1523.  
  1524.         Type of a dialect info record containing at least keyOSADialectName
  1525.         and keyOSADialectCode fields.
  1526.  
  1527.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1528.  
  1529.         Field of a typeOSADialectInfo record of typeChar.
  1530.         Field of a typeOSADialectInfo record of typeShortInteger.
  1531.         Field of a typeOSADialectInfo record of typeShortInteger.
  1532.         Field of a typeOSADialectInfo record of typeShortInteger.
  1533.     */
  1534. /**************************************************************************
  1535.     OSA Optional Event Handling Interface
  1536. **************************************************************************
  1537.     Scripting components that support the Event Handling interface have the 
  1538.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1539. **************************************************************************/
  1540. EXTERN_API( OSAError )
  1541. OSASetResumeDispatchProc        (ComponentInstance         scriptingComponent,
  1542.                                  AEEventHandlerUPP         resumeDispatchProc,
  1543.                                  long                     refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0801, 0x7000, 0xA82A);
  1544.  
  1545. /*
  1546.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1547.         This function is used to set the ResumeDispatchProc that will be used
  1548.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1549.         found in the context, or the context event hander "continues" control
  1550.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1551.         may also be passed to this routine indicating that the handler registered
  1552.         in the application with AEInstallEventHandler should be used, or no
  1553.         dispatch should occur, respectively.
  1554.     
  1555.         Errors:
  1556.             badComponentInstance    invalid scripting component instance
  1557.             errOSASystemError
  1558.     */
  1559.  
  1560. enum {
  1561.     kOSAUseStandardDispatch        = kAEUseStandardDispatch
  1562. };
  1563.  
  1564. /*
  1565.         Special ResumeDispatchProc constant which may be passed to 
  1566.         OSASetResumeDispatchProc indicating that the handler registered
  1567.         in the application with AEInstallEventHandler should be used.
  1568.         
  1569.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1570.                 doesn't allow pointer types to be assigned to an enum.  All
  1571.                 constants must be assigned as enums to translate properly to
  1572.                 Pascal.
  1573.     */
  1574.  
  1575. enum {
  1576.     kOSANoDispatch                = kAENoDispatch
  1577. };
  1578.  
  1579. /*
  1580.         Special ResumeDispatchProc constant which may be passed to 
  1581.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1582.         
  1583.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1584.                 doesn't allow pointer types to be assigned to an enum.  All
  1585.                 constants must be assigned as enums to translate properly to
  1586.                 Pascal.
  1587.     */
  1588.  
  1589. enum {
  1590.     kOSADontUsePhac                = 0x0001
  1591. };
  1592.  
  1593. /*
  1594.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1595.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1596.         This causes the standard dispatch to be performed, except the phac
  1597.         handler is not called.  This is useful during tinkerability, when
  1598.         the phac handler is used to lookup a context associated with an event's 
  1599.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1600.         bypass the phac handler would result in an infinite loop.
  1601.     */
  1602. EXTERN_API( OSAError )
  1603. OSAGetResumeDispatchProc        (ComponentInstance         scriptingComponent,
  1604.                                  AEEventHandlerUPP *    resumeDispatchProc,
  1605.                                  long *                    refCon)                                FIVEWORDINLINE(0x2F3C, 0x0008, 0x0802, 0x7000, 0xA82A);
  1606.  
  1607. /*
  1608.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1609.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1610.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1611.     
  1612.         Errors:
  1613.             badComponentInstance    invalid scripting component instance
  1614.             errOSASystemError
  1615.     */
  1616. EXTERN_API( OSAError )
  1617. OSAExecuteEvent                    (ComponentInstance         scriptingComponent,
  1618.                                  const AppleEvent *        theAppleEvent,
  1619.                                  OSAID                     contextID,
  1620.                                  long                     modeFlags,
  1621.                                  OSAID *                resultingScriptValueID)                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0803, 0x7000, 0xA82A);
  1622.  
  1623. /*
  1624.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1625.         This call is similar to OSAExecute except the initial command to
  1626.         execute comes in the form of an AppleEvent.  If the contextID
  1627.         defines any event handlers for that event, they are used to process
  1628.         the event.  If no event handler can be found in the context
  1629.         errAEEventNotHandled is returned.  If an event handler is found and
  1630.         the hander "continues" control onward, the ResumeDispatchProc
  1631.         (registered with OSASetResumeDispatchProc, above) is called given the
  1632.         AppleEvent.  The result is returned as a scriptValueID.
  1633.     
  1634.         Errors:
  1635.             badComponentInstance    invalid scripting component instance
  1636.             errOSASystemError
  1637.             errOSAInvalidID
  1638.             errOSAScriptError:        the executing script got an error
  1639.             errAEEventNotHandled:    no handler for event in contextID
  1640.     
  1641.         ModeFlags:
  1642.             kOSAModeNeverInteract
  1643.             kOSAModeCanInteract
  1644.             kOSAModeAlwaysInteract
  1645.             kOSAModeCantSwitchLayer
  1646.             kOSAModeDontReconnect
  1647.             kOSAModeDoRecord
  1648.     */
  1649. EXTERN_API( OSAError )
  1650. OSADoEvent                        (ComponentInstance         scriptingComponent,
  1651.                                  const AppleEvent *        theAppleEvent,
  1652.                                  OSAID                     contextID,
  1653.                                  long                     modeFlags,
  1654.                                  AppleEvent *            reply)                                FIVEWORDINLINE(0x2F3C, 0x0010, 0x0804, 0x7000, 0xA82A);
  1655.  
  1656. /*
  1657.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1658.         This call is similar to OSADoScript except the initial command to
  1659.         execute comes in the form of an AppleEvent, and the result is an 
  1660.         AppleEvent reply record.  If the contextID defines any event handlers
  1661.         for that event, they are used to process the event.  If no event handler
  1662.         can be found in the context errAEEventNotHandled is returned.  If an
  1663.         event handler is found and the hander "continues" control onward, the
  1664.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1665.         called given the AppleEvent.  The result is returned in the form of an
  1666.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1667.         if the ResumeDispatchProc returns a reply event indicating an error,
  1668.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1669.         should never return errOSAScriptError).  Any error result returned by
  1670.         the ResumeDispatchProc will be returned by OSADoEvent.
  1671.     
  1672.         Errors:
  1673.             badComponentInstance    invalid scripting component instance
  1674.             errOSASystemError
  1675.             errOSAInvalidID
  1676.             errAEEventNotHandled:    no handler for event in contextID
  1677.     
  1678.         ModeFlags:
  1679.             kOSAModeNeverInteract
  1680.             kOSAModeCanInteract
  1681.             kOSAModeAlwaysInteract
  1682.             kOSAModeCantSwitchLayer
  1683.             kOSAModeDontReconnect
  1684.             kOSAModeDoRecord
  1685.     */
  1686. EXTERN_API( OSAError )
  1687. OSAMakeContext                    (ComponentInstance         scriptingComponent,
  1688.                                  const AEDesc *            contextName,
  1689.                                  OSAID                     parentContext,
  1690.                                  OSAID *                resultingContextID)                    FIVEWORDINLINE(0x2F3C, 0x000C, 0x0805, 0x7000, 0xA82A);
  1691.  
  1692. /*
  1693.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1694.         Makes a new empty context which may be passed to OSAExecute or 
  1695.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1696.         created. If parentContext is kOSANullScript then the resulting context
  1697.         does not inherit bindings from any other context.
  1698.     
  1699.         Errors:
  1700.             badComponentInstance    invalid scripting component instance
  1701.             errOSASystemError
  1702.             errOSAInvalidID
  1703.             errAECoercionFail:        contextName is invalid
  1704.     */
  1705.  
  1706.  
  1707. #if PRAGMA_STRUCT_ALIGN
  1708.     #pragma options align=reset
  1709. #elif PRAGMA_STRUCT_PACKPUSH
  1710.     #pragma pack(pop)
  1711. #elif PRAGMA_STRUCT_PACK
  1712.     #pragma pack()
  1713. #endif
  1714.  
  1715. #ifdef PRAGMA_IMPORT_OFF
  1716. #pragma import off
  1717. #elif PRAGMA_IMPORT
  1718. #pragma import reset
  1719. #endif
  1720.  
  1721. #ifdef __cplusplus
  1722. }
  1723. #endif
  1724.  
  1725. #endif /* __OSA__ */
  1726.  
  1727.